Class {
	#name : 'RGPointerLayout',
	#superclass : 'RGLayout',
	#instVars : [
		'slots'
	],
	#category : 'Ring-Core-Kernel',
	#package : 'Ring-Core',
	#tag : 'Kernel'
}

{ #category : 'accessing - backend' }
RGPointerLayout >> addSlot: anRGSlot [

	self parent announceDefinitionChangeDuring: [
		self backend forBehavior addSlot: anRGSlot to: self ]
]

{ #category : 'queries - slots' }
RGPointerLayout >> allSlots [

	^ self slots
]

{ #category : 'accessing - backend' }
RGPointerLayout >> cleanSlots [

	self parent announceDefinitionChangeDuring: [
		self backend forBehavior cleanSlotsFor: self ]
]

{ #category : 'default model values' }
RGPointerLayout >> defaultSlots [

	^ OrderedCollection new
]

{ #category : 'initialization' }
RGPointerLayout >> initialize [

	super initialize.
	slots := self unresolvedValue: self defaultSlots
]

{ #category : 'initialization' }
RGPointerLayout >> initializeUnresolved [

	super initializeUnresolved.
	slots := self unresolvedValue: self defaultSlots
]

{ #category : 'queries - slots' }
RGPointerLayout >> instVarNames [
	^ self slots collect: [:each | each name]
]

{ #category : 'testing - types' }
RGPointerLayout >> isPointerLayout [

	^ true
]

{ #category : 'resolving' }
RGPointerLayout >> makeResolved [

	super makeResolved.

	"We want to ensure we have an ordered collection because we can add slocts to the model and we cannot do it if it's an array"
	slots := self slots asOrderedCollection do: [ :each | each markAsRingResolved ]
]

{ #category : 'private - backend access' }
RGPointerLayout >> pvtAddSlot: anRGSlot [

	self environment verifyOwnership: anRGSlot.

	slots isRingResolved ifFalse: [
		self pvtCleanSlots  ].

	slots add: anRGSlot
]

{ #category : 'private - backend access' }
RGPointerLayout >> pvtCleanSlots [

	slots := self defaultSlots
]

{ #category : 'private - backend access' }
RGPointerLayout >> pvtRemoveSlot: anRGSlot [

	self environment verifyOwnership: anRGSlot.

	slots remove: anRGSlot
]

{ #category : 'private - backend access' }
RGPointerLayout >> pvtResolvableProperties [

	^ super pvtResolvableProperties, {
		#slots -> slots.
	}
]

{ #category : 'private - backend access' }
RGPointerLayout >> pvtSlotsDo: aBlock [

	slots value do: aBlock
]

{ #category : 'accessing - backend' }
RGPointerLayout >> removeSlot: anRGSlot [

	self parent announceDefinitionChangeDuring: [
		self backend forBehavior removeSlot: anRGSlot from: self ]
]

{ #category : 'accessing' }
RGPointerLayout >> resolveSlot: aName ifFound: foundBlock ifNone: noneBlock [

	self allSlots do: [ :slot |
		slot name = aName ifTrue: [ ^ foundBlock cull: slot ] ].
	^ noneBlock value
]

{ #category : 'queries - slots' }
RGPointerLayout >> slots [

	| allSlots |
	allSlots := OrderedCollection new.
	self slotsDo: [ :each | allSlots add: each].
	^ allSlots asArray
]

{ #category : 'accessing - backend' }
RGPointerLayout >> slotsDo: aBlock [

	self backend forBehavior slotsFor: self do: aBlock
]
